package de.baumann.browser.api.net

import de.baumann.browser.BuildConfig
import de.baumann.browser.api.net.base.BaseUrl
import de.baumann.browser.api.net.vo.Result
import de.baumann.browser.api.net.vo.gg.*
import io.reactivex.Observable
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST

@BaseUrl(BuildConfig.GG_API)
interface GGApiService {

    @FormUrlEncoded
    @POST("gungnir/smeltery/createSmeltery")
    fun createSmeltery(@Field("name") name: String,
                       @Field("address") address: String,
                       @Field("transactionHash") transactionHash: String,
                       @Field("profit") profit: String,
                       @Field("month") month: String): Observable<Result<Any>>


    @FormUrlEncoded
    @POST("gungnir/smeltery/joinSmeltery")
    fun joinSmeltery(@Field("smelteryId") smelteryId: String,
                     @Field("address") address: String,
                     @Field("transactionHash") transactionHash: String,
                     @Field("profit") profit: String,
                     @Field("month") month: String): Observable<Result<Any>>


    @FormUrlEncoded
    @POST("gungnir/smeltery/prepositionByAddress")
    fun prepositionByAddress(
            @Field("address") address: String): Observable<Result<GGMain>>


    @FormUrlEncoded
    @POST("gungnir/smeltery/getPledgeRule")
    fun getPledgeRule(@Field("type") type: String): Observable<Result<GGRule>>


    @POST("gungnir/smeltery/smelteryRank")
    fun smelteryRank(): Observable<Result<List<Smelter>>>

    @FormUrlEncoded
    @POST("gungnir/mySmelteryController/getPledgeLog")
    fun getPledgeLog(@Field("smelteryId") smelteryId: String): Observable<Result<List<Morgage>>>


    @FormUrlEncoded
    @POST("gungnir/record/morgage")
    fun morgageRecord(@Field("address") address: String): Observable<Result<List<Morgage>>>


    @FormUrlEncoded
    @POST("gungnir/mySmelteryController/getPledgeNumAndEarnings")
    fun getPledgeNumAndEarnings(@Field("userAddress") userAddress: String,
                                @Field("smelteryId") smelteryId: String): Observable<Result<XXYY>>

    @FormUrlEncoded
    @POST("gungnir/record/total")
    fun recordTotal(@Field("address") address: String): Observable<Result<XXYY>>

    @FormUrlEncoded
    @POST("gungnir/smeltery/redemption")
    fun redemption(@Field("address") address: String,
                   @Field("profit") profit: String,
                   @Field("transactionHash") transactionHash: String
    ): Observable<Result<Any>>

    @FormUrlEncoded
    @POST("gungnir/smeltery/getExtractTrans")
    fun getExtractTrans(@Field("address") address: String): Observable<Result<List<ExtractTrans>>>

    @FormUrlEncoded
    @POST("gungnir/smeltery/selectSameName")
    fun selectSameName(@Field("smelteryName")name:String):Observable<Result<F>>

}